﻿#region NeoPatterns
// 
// NeoPatterns framework is released under LGPLv3 license.
// See http://www.opensource.org/licenses/lgpl-3.0.html for more details.
// 
// Please visit http://neopatterns.wikidot.com for more information about NeoPatterns
// 
// Copyright (c) Pascal Craponne 2008
// 
#endregion

using System.Reflection;
using NeoPatterns.Core.Aop;

namespace NeoPatterns.Utility
{
    public static class InvocationExtension
    {
        public static T GetClaims<T>(this IInvocation invocation, PropertyInfo claimProperty)
        {
            return (T)claimProperty.GetGetMethod().Invoke(invocation.Target, null);
        }

        public static void SetClaims<T>(this IInvocation invocation, PropertyInfo claimProperty, T claim)
        {
            claimProperty.GetSetMethod().Invoke(invocation.Target, new object[] { claim });
        }
    }
}
